package com.itheima.dao;

import com.itheima.pojo.Member;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.Date;

public interface MemberDao {

    //通过手机号查询用户
    @Select("select * from t_member where phoneNumber= #{telephone}")
    Member findTelePhone(String telephone);

    @Insert("insert into t_member values(null,null,#{name},#{sex},#{idCard},#{phoneNumber},#{regTime},null,null,null,null)")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void add(Member member);

    @Select("select count(id) from t_member where regTime <= #{month}")
    Integer findMemberCountByMonths(String month);

    //今日注册人数
    @Select("select count(id) from t_member where regTime = #{reportDate}")
    Integer findMemberCountByToday(String reportDate);

    //总预约人数
    @Select("select count(id) from t_member")
    Integer findTotalMember();

    //本周/本月预约人数
    @Select("select count(id) from t_member where regTime >= #{date}")
    Integer findMemberCountByDate(String date);
}
